{% extends 'basic.html' %}

{% block extra-head %}
<link type="text/css" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" rel="stylesheet"/>
<script type="text/javascript" src="http://books.google.com/books/previewlib.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script src="/static/js/yt.js" type="text/javascript" charset="utf-8"></script>
{% endblock %}

{% block header %}
<h1>Twoje wypożyczenia{% if history %}<small> historia poniżej</small>{% endif %}</h1>
{% endblock %}

{% block content %}
<script type="text/javascript" src="http://books.google.com/books/previewlib.js"></script>
<table class="table table-hover">
    <thead>
        <tr>
            <th>Tytuł</th>
            <th>Autor</th>
            <th>Nośnik</th>
            <th>Kiedy zwrot</th>
        </tr>
    </thead>
    <tbody>
    {% for order in orders %}
    <tr>
        <td>
            {% if order.item.url %}
            <a class="yt" rel="{{order.item.url}}" href="#">{{order.item.title}}</a>
            {% elif order.item.isbn %}
            <a href="#">{{order.item.title}}</a>
            <script type="text/javascript">
                GBS_insertPreviewButtonPopup('ISBN:{{order.item.isbn}}');
            </script>
            {% else  %}
            {{order.item.title}}
            {% endif %}
        </td>
        <td>{{order.item.author}}&nbsp;<a href="/query/?query={{order.item.author}}&media=all&author=true"><i class="icon-share-alt" title="Więcej tego autora"></i></a></td>
        <td>{{order.item.media.as_icon|safe}}</td>
        <td>{{order.due_date|timeuntil}}</td>
    </tr>
    {% endfor %}
    </tbody>
    <tbody>
    {% if history %}
    <tr>
        <td colspan=4>Historia zamówień</td>
    </tr>
    {% endif %}
    {% for his in history %}
    <tr>
        <td>{{his.item.title}}</td>
        <td>{{his.item.author}}&nbsp;<a href="/query/?query={{order.item.author}}&media=all&author=true"><i class="icon-share-alt" title="Więcej tego autora"></i></a></td>
        <td>{{his.item.media.as_icon|safe}}</td>
        <td>{{his.due_date}}</td>
    </tr>
    {% endfor %}
    </tbody>
</table>
{% endblock %}

{% block sidebar %}
    <div class="well">
    Pamiętaj, by zwrócić wypożyczone pozycje na czas
    </div>
{% endblock %}
